Source for file compat.php42x.php
Documentation is available at compat.php42x.php
/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
* Replace file_get_contents()
* @link http://php.net/function.file_get_contents
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @internal resource_context is not supported
* @require PHP 4.0.1 (trigger_error)
if (false ===
$fh =
fopen($filename, 'rb', $incpath)) {
trigger_error('file_get_contents() failed to open stream: No such file or directory', E_USER_WARNING);
$data =
fread($fh, $fsize);
$data .=
fread($fh, 8192);
if (!defined('FILE_USE_INCLUDE_PATH')) {
define('FILE_USE_INCLUDE_PATH', 1);
* Replace file_put_contents()
* @link http://php.net/function.file_put_contents
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @internal resource_context is not supported
* @require PHP 4.0.1 (trigger_error)
function file_put_contents($filename, $content, $flags =
null, $resource_context =
null)
// If $content is an array, convert it to a string
// If we don't have a string, throw an error
trigger_error('file_put_contents() The 2nd parameter should be either a string or an array', E_USER_WARNING);
// Get the length of date to write
// Check what mode we are using
// Check if we're using the include path
// Open the file for writing
if (($fh =
@fopen($filename, $mode, $use_inc_path)) ===
false) {
trigger_error('file_put_contents() failed to open stream: Permission denied', E_USER_WARNING);
if (($bytes =
@fwrite($fh, $content)) ===
false) {
$errormsg =
sprintf('file_put_contents() Failed to write %d bytes to %s',
// Check all the data was written
$errormsg =
sprintf('file_put_contents() Only %d of %d bytes written, possibly out of free disk space.',
Documentation generated on Mon, 05 May 2008 16:18:02 +0400 by phpDocumentor 1.4.0